var ClubAssistantInviteItem = Item.extend({
    _ccsFileName: res.ClubAssistantInviteItem_json,
    _data: null,
    _clubId: null,
    _roomInfo: null,
    onEnter: function () {
        Item.prototype.onEnter.call(this);
        this._addClickListeners();
    },

    _initClickListeners: function () {
        this._clickListeners = {
            'btn_yaoqing': '_clickInvite',
        }
    },

    refreshData: function (idx, data, clubId,roomInfo) {
        this._roomInfo = roomInfo;
        this._data = data;
        this._clubId = clubId;
        loadImageToSprite(data['headUrl'], this._nodeList['head']);
        this._nodeList['lb_num'].setString(idx);
        this._nodeList['lb_name'].setString(ellipsisStr(data['name'], 6));

        this._nodeList['btn_yaoqing'].setVisible(true);
        if (data['state'] == ClubDataManager.MemberState_Room || data['black']) {
            this._nodeList['btn_yaoqing'].setVisible(false);
        }
        if (data['black']) {
            this._nodeList['lb_states'].setString(data['blackTips']);
        } else {
            this._nodeList['lb_states'].setString(data['stateTips']);
        }
        if (data['state'] == ClubDataManager.MemberState_Room || data['black']) {
            this._nodeList['lb_states'].setTextColor(cc.color(222, 87, 82));
        } else {
            this._nodeList['lb_states'].setTextColor(cc.color(89, 136, 232));
        }
    },

    _clickInvite: function () {
        var clubInfo = ClubDataManager.getClubData(this._clubId);
        var wanfa = gameData.wanfaDesp || this._roomInfo.wanfa;
        var descList = wanfa.split(',');
        var options = gameData.options || this._roomInfo['options'] || JSON.parse(this._roomInfo['option']);
        var roomId = gameData.roomId || this._roomInfo.room_id;

        var message = {
            type: MessageType.Invite,
            uids: this._data['uid'],
            room_id: roomId,
            player_name: gameData.nickname,
            wanfa_name: descList[0] + '(' + (options['maxPlayerNum'] || 0) + '人' + ')',
            wanfa_desc: decodeURIComponent(wanfa),
            club_name: clubInfo.name,
        };
        var data = {
            cmd: ClubMsgCode.BroadcastUid,
            club_id: this._clubId,
            uids: this._data['uid'].toString(),
            data: message,
            from_uid: gameData.uid,
        };
        network.send(2103, data);
        this._nodeList['btn_yaoqing'].setVisible(false);
    },
});